package com.book.controller;

import com.book.po.classroom;
import com.book.service.classroomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import java.util.List;

@Controller
@RequestMapping("/classroom")
public class classroomController {
    @Autowired
    private classroomService classroomService;

    @RequestMapping("/room_select")
    public String book_select(RedirectAttributes  model, classroom room){
        List<classroom> rooms = classroomService.room_select(room);
        if (rooms.size()>=1){
            model.addFlashAttribute("rooms",rooms);
            model.addFlashAttribute("msg","");
            return "redirect:/user/siteorder";
        }else {
            model.addFlashAttribute("msg","无可用教室！");
            return "redirect:/user/siteorder";
        }
    }

//    @RequestMapping("/book_insert")
//    public String book_insert(RedirectAttributes  model, Book book){
//        if (book!=null) {
//            book.setCurrentNum(book.getNum());
//        }
//        String msg = bookService.book_insert(book);
//
//        model.addFlashAttribute("msg",msg);
//        return "redirect:/manage/bookManage";
//    }
//
//    @RequestMapping("/book_update")
//    public String book_update(RedirectAttributes  model, Book book){
//        String msg = bookService.book_update(book);
//        model.addFlashAttribute("msg",msg);
//        return "redirect:/manage/bookManage";
//    }
//
//    @RequestMapping("/book_delete")
//    public String book_delete(RedirectAttributes  model, Integer bookId){
//        String msg = bookService.book_delete(bookId);
//        model.addFlashAttribute("msg",msg);
//        return "redirect:/manage/bookManage";
//    }
}
